package com.hmall.feign.client;

import com.hmall.feign.dto.Item;
import com.hmall.feign.dto.PageDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

@FeignClient("item-service")
@RequestMapping("/mall/item")
public interface ItemClient {

    @GetMapping("/list")
    PageDTO<Item> queryItemByPage(@RequestParam("page") Integer page,
                                  @RequestParam("size") Integer size);

    @GetMapping("/{id}")
    Item queryItemById(@PathVariable("id") Long id);

    @PostMapping
    void saveItem(@RequestBody Item item);

    @PutMapping("/status/{id}/{status}")
    void updateItemStatus(@PathVariable("id") Long id, @PathVariable("status") Integer status);

    @PutMapping
    void updateItem(@RequestBody Item item);

    @DeleteMapping("{id}")
    void deleteItemById(@PathVariable("id") Long id);

    @PutMapping("/stock/{itemId}/{num}")
    void updateStock(@PathVariable("itemId") Long itemId, @PathVariable("num") Integer num);

    @PutMapping("/add/{itemId}/{num}")
    void addStock(@PathVariable("itemId") Long itemId, @PathVariable("num") Integer num);
}
